const base64Symbol = "base64,";

const base64Split = (str: string) => {
  let result = str && str.trim() ? [str] : [];
  if (str && typeof str === "string") {
    if (str.indexOf(base64Symbol) !== -1) {
      const orignList = str.split(",");
      const base64List: string[] = [];
      for (let i = 0; i < orignList.length; i++) {
        const front = orignList[i];
        // base64格式的图片
        if (front.startsWith("data:")) {
          const later = orignList[i + 1];
          base64List.push(`${front},${later}`);
          i++;
        } else {
          // 普通链接图片
          base64List.push(`${front}`);
        }
      }
      result = base64List;
    } else {
      result = str.indexOf(",") !== -1 ? str.split(",") : [str];
    }
  }
  return result;
};


const fileStr = "data:img/png;base64,xxxxx,data:img/png;base64,yyyyy,http://localhost:8888/nginx-images/test.png,data:img/png;base64,zzzz";
const list = base64Split(fileStr);

console.log("list: ", list);